Service.restart   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 2
1
import OS from '../client/OS'
2
3
abstract class Service {
4
    abstract service: string
5
    requireRoot = false
6
7
    start = async (): Promise<boolean> =>
8
        this.requireRoot ?
9
            OS.getInstance().serviceCtl.startAsRoot(this.service) :
10
            OS.getInstance().serviceCtl.start(this.service)
11
12
    stop = async (): Promise<boolean> =>
13
        this.requireRoot ?
14
            OS.getInstance().serviceCtl.stopAsRoot(this.service) :
15
            OS.getInstance().serviceCtl.stop(this.service)
16
17
    restart = async (): Promise<boolean> =>
18
        this.requireRoot ?
19
            OS.getInstance().serviceCtl.restartAsRoot(this.service) :
20
            OS.getInstance().serviceCtl.restart(this.service)
21
22
    reload = async (): Promise<boolean> =>
23
        this.requireRoot ?
24
            OS.getInstance().serviceCtl.reloadAsRoot(this.service) :
25
            OS.getInstance().serviceCtl.reload(this.service)
26
27
    install = (): Promise<boolean> => {
28
        return OS.getInstance().packageManager.install(this.service, false)
29
    }
30
31
    uninstall = (): Promise<boolean> => {
32
        return OS.getInstance().packageManager.uninstall(this.service, false)
33
    }
34
35
    abstract configure(): Promise<boolean>
36
}
37
38
export default Service
39